import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDLordPraySkill {
	/**祝福id*/
	id,
	/**最大等级*/
	maxLv,
	/**效果类型*/
	effectType,
	/**效果参数*/
	param,
	/**效果参数成长*/
	paramGrow,
	/**名称*/
	name,
	/**描述*/
	desc,
	/**图标*/
	icon,

	/**枚举数量*/
	EnumCount
}



export class CDLordPraySkill{
	/**祝福id*/
	public id: number;
	/**最大等级*/
	public maxLv: number;
	/**效果类型*/
	public effectType: number;
	/**效果参数*/
	public param: number;
	/**效果参数成长*/
	public paramGrow: number;
	/**名称*/
	public name: number;
	/**描述*/
	public desc: number;
	/**图标*/
	public icon: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDLordPraySkill.id: return this.id;
			case E_CDLordPraySkill.maxLv: return this.maxLv;
			case E_CDLordPraySkill.effectType: return this.effectType;
			case E_CDLordPraySkill.param: return this.param;
			case E_CDLordPraySkill.paramGrow: return this.paramGrow;
			case E_CDLordPraySkill.name: return this.name;
			case E_CDLordPraySkill.desc: return this.desc;
			case E_CDLordPraySkill.icon: return this.icon;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDLordPraySkill.id: this.id = v; break;
			case E_CDLordPraySkill.maxLv: this.maxLv = v; break;
			case E_CDLordPraySkill.effectType: this.effectType = v; break;
			case E_CDLordPraySkill.param: this.param = v; break;
			case E_CDLordPraySkill.paramGrow: this.paramGrow = v; break;
			case E_CDLordPraySkill.name: this.name = v; break;
			case E_CDLordPraySkill.desc: this.desc = v; break;
			case E_CDLordPraySkill.icon: this.icon = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDLordPraySkill> = new HashMap<number, CDLordPraySkill>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDLordPraySkill[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDLordPraySkill();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].maxLv = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].effectType = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].param = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].paramGrow = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].name = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].desc = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].icon = byte.readInt32();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDLordPraySkill{
		return this.datas ? this.datas.get(id) : null;
	}
}
